package com.incar.chuxing.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.incar.chuxing.R;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by 17310 on 2018/1/19.
 */

public class YongCheQuanXianLvAdapter extends BaseAdapter {
    private List<String> mlist;
    private Context mContext;

    public YongCheQuanXianLvAdapter(List<String> list, Context context) {
        this.mlist = list;
        this.mContext = context;
    }

    @Override
    public int getCount() {
        return mlist != null ? mlist.size() : 0;
    }

    @Override
    public Object getItem(int i) {
        return mlist != null ? mlist.get(i) : null;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.permision_lv_item, parent, false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.permisionLvItemTv.setText(mlist.get(position));
        return convertView;
    }


    static class ViewHolder {
        @BindView(R.id.permision_lv_item_tv)
        TextView permisionLvItemTv;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
